cc.Class({
    extends: cc.Component,

    properties: {
        playTab:'shuangkou',
        play:{
            default:null,
            type:cc.Node
        }
    },

    onLoad: function () {
        this.initTab(this.play.children,this.playTab);
    },
    initTab:function(tabs,activeTab){
        tabs.map(function(item){
            if(activeTab==item.name){
                item.getChildByName('back').active=true;
                if(item.getChildByName('text')){
                    item.getChildByName('text').active=true;
                }
            }else{
                item.getChildByName('back').active=false;
                if(item.getChildByName('text')){
                    item.getChildByName('text').active=false;
                }
            }
        })
    },
    initView:function(tabs,activeTab){
        tabs.map(function(item){
            if(activeTab==item.name){
                item.getChildByName('back').active=true;
            }else{
                item.getChildByName('back').active=false;
            }
        })
    },
    //回放
    playTabClick:function(e,data){
        console.log(data)
        if(this.playTab!=e.currentTarget.name){
           this.playTab=e.currentTarget.name;
           this.initView(this.play.children,this.playTab);
        }
    },
    //规则
    tabClick:function(e){
        console.log(e.currentTarget.name)
        if(this.playTab!=e.currentTarget.name){
           this.playTab=e.currentTarget.name;
           this.initTab(this.play.children,this.playTab);
        }
    }
});
